class County < ActiveRecord::Base
  belongs_to  :duchy
  has_many    :towns
  has_many      :populations
  
  def County.with_ruler(character)
    return nil unless character
    counties = County.find(:all)
    for county in counties
      ruler = county.ruler
      return county unless ruler.nil? or ruler.id != character.id
    end
    return nil
  end
  
  def ruler
    Title.count_of self
  end
end
